<?php

namespace App\SubApps\Account\Models;

use App\SubApps\Account\Traits\ModelSetConnectionMysqlTrait;
use Hilaoyu\LaravelExtend\Model;

 class OauthAppsLoginLogModel extends Model
{

    use ModelSetConnectionMysqlTrait;
    protected $table = 'oauth_apps_login_log';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'token_id' ,
        'user_id' ,
        'user_model' ,
        'login_platform' ,
        'login_source' ,
        'login_ip' ,
        'referer' ,
        'oauth_app_id' ,
        'oauth_app_return' ,
        'oauth_app_state' ,
    ];

    protected $hidden = [
        'user_model',
    ];

    public function getValidationRules()
    {
        $rules = [
            'user_id' => 'required|uuid',
            'user_model' => 'required|string',
            'oauth_app_id' => 'required|uuid',
        ];

        return $rules;
    }


    public function oauth_app(){
        return $this->hasOne(
            OauthAppsModel::class,
            'id',
            'oauth_app_id'
        );
    }

    public function login_user(){
        return $this->hasOne(
            AuthUsersModel::class,
            'id',
            'user_id'
        );
    }

}
